package edu.scau.divineplace.controller;

import edu.scau.divineplace.config.global.log.WebLog;
import edu.scau.divineplace.entity.enums.RoleTruthEnum;
import edu.scau.divineplace.entity.query.PageQuery;
import edu.scau.divineplace.entity.vo.content.ContentSimplyInfoVO;
import edu.scau.divineplace.entity.vo.role.*;
import edu.scau.divineplace.service.RoleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author: x1aolone
 * @Date: 2020/12/11 15:47
 */
@Slf4j
@RestController
@CrossOrigin
@Api("Role控制器")
@WebLog("Role控制器")
@RequestMapping("/role")
public class RoleController {

    @Autowired
    private RoleService roleService;

    @ApiOperation("通过内容id获取内容的角色列表")
    @GetMapping("/list/{contentId}")
    public List<RoleVO> getRoleList(@PathVariable Long contentId) {
        return roleService.getRoleList(contentId);
    }

    @ApiOperation("通过角色id获取角色的真实性")
    @GetMapping("/roleTruth/judge/{roleId}")
    public Boolean judgeRoleTruth(@PathVariable Long roleId) {
        return roleService.judgeRoleTruth(roleId);
    }

    @ApiOperation("通过角色id获取角色的真实性")
    @GetMapping("/roleTruth/get/{roleId}")
    public RoleTruthEnum getRoleTruth(@PathVariable Long roleId) {
        return roleService.getRoleTruth(roleId);
    }



    @ApiOperation("通过虚拟角色id获取角色出演的内容，支持分页")
    @GetMapping("/virtual/perform/list/{roleId}")
    public List<PerformVO> listVirtualPerform(@PathVariable Long roleId, Integer currentPage, Integer pageSize){
        return roleService.listVirtualPerform(roleId, currentPage, pageSize);
    }

    @ApiOperation("通过真实角色id获取角色最近担任cv的内容，支持分页")
    @GetMapping("/real/recentCVRole/list/{cvId}")
    public List<CVContentRoleVO> listRealRecentCVRole(@PathVariable Long cvId, Integer currentPage, Integer pageSize){
        return roleService.listRealRecentCVRole(cvId, currentPage, pageSize);
    }

    @ApiOperation("通过内容id获取内容的制作人，支持分页")
    @GetMapping("/producer/list/{contentId}")
    public List<ProducerVO> listProducer(@PathVariable Long contentId, Integer currentPage, Integer pageSize){
        return roleService.listProducer(contentId, currentPage, pageSize);
    }

    @ApiOperation("通过获取最近更新的人物，完美分页")
    @GetMapping("/recent")
    public List<RoleSimplyInfoVO> listRecentRole (PageQuery pageQuery) {
        return roleService.listRecentRole(pageQuery);
    }

    @ApiOperation("通过获取最近更新的人物，完美分页")
    @GetMapping("/rank")
    public List<RoleSimplyInfoVO> listRankRole (PageQuery pageQuery) {
        return roleService.listRankRole(pageQuery);
    }

}
